<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>1024博客-登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/assets/css/toastr.css}">
</head>

<body th:background="@{/assets/img/back.jpg}">
<div class="layui-container">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md4 ">
            <div></div>
        </div>
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md4" >
            <form class="layui-form layui-font-gray layui-anim layui-anim-scaleSpring" lay-filter="example" id="loginForm" th:action="@{/login}" method="post" style="border: 1px solid  blue;vertical-align: middle;margin-top: 200px">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
                    <legend>1024博客 -用户登录</legend>
                    <input type="hidden" name="url" th:value="${url}">
                </fieldset>
                <div class="text-center" th:if="${param.error}" style="color: red" th:text="#{login.error}">用户名或密码错误!</div>
                <div class="layui-form-item">
                    <label class="layui-form-label ">用户名</label>
                    <div class="layui-input-block">
                        <input type="text" name="username" lay-verify="required" lay-reqText="请输入用户名"	autocomplete="off" placeholder="请输入用户名" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input type="password" name="password" placeholder="请输入密码" lay-verify="required|passwordRule" lay-reqText="请输入密码" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">记住我</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="rememberme" lay-skin="switch">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="layui-btn layui-anim layui-anim-scaleSpring" lay-submit="" lay-filter="login" th:value="#{login.sub}">登录</button>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <a href="/register">
                            <button type="button" class="layui-btn layui-btn-xs  layui-btn-radius  layui-btn-normal" >注册</button>
                        </a>
                        <a href="/forget">
                            <button type="button" class="layui-btn layui-btn-xs  layui-btn-radius  layui-btn-normal" >忘记密码</button>
                        </a>
                    </div>
                </div>
            </form>
        </div>
        <div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
            <div></div>
        </div>
    </div>
    <footer class="log-footer">
        <p style="margin: 30px; color: #2E2D3C">
            <time class="comment-time" th:text="${#dates.format(new java.util.Date().getTime(), 'yyyy')}"></time> &copy;
            Powered By <a style="color: #0e90d2" rel="nofollow">CrazyStone</a></p>
    </footer>
</div>
<script th:src="@{/assets/js/jquery.min.js}"></script>
<script th:src="@{/layui/layui.js}" charset="utf-8"></script>
<script th:src="@{/assets/js/toastr.min.js}"></script>
<script type="text/javascript">
    function login() {
        $.ajax({
            type: "POST",
            url: '/login',
            data: $('#loginForm').serialize(),
            async: false,
            dataType: 'json',
            error: function (result) {
                $('#tips').text(result);
            },
        })
    }
</script>

</body>
</html>